package com.kofigyan.stateprogressbarsample;

import com.kofigyan.stateprogressbarsample.not_stateprogressbar.adapter.StatesListAdapter;
import com.kofigyan.stateprogressbarsample.not_stateprogressbar.utils.Constants;
import ohos.aafwk.content.Intent;

import java.util.ArrayList;
import java.util.List;

public class StatesListActivity extends ListBaseActivity {

    private boolean isDescending;
    private boolean isDescendingAscendingOptions;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        isDescending = getIntent().getBooleanParam(Constants.DESCENDING, false);
        isDescendingAscendingOptions = getIntent()
                .getBooleanParam(Constants.IS_DESCENDING_ASCENDING_OPTIONS, false );

        List<String> items = getItems();

        StatesListAdapter adapter = new StatesListAdapter(this, items, isDescending);

        recyclerView.setItemProvider(adapter);
    }

    @Override
    protected int getLayoutId() {
        return ResourceTable.Layout_ability_states_list;
    }

    private List<String> getItems() {
        List<String> items = new ArrayList<>();
        String[] statesItems = new String[]{};
        if (isDescendingAscendingOptions) {
            statesItems = new String[]{
                    "Ascending",
                    "Descending",
            };
        } else {
            statesItems = new String[]{
                    "5 States",
                    "4 States",
                    "3 States",
                    "2 States",
            };
        }

        for (int i = 0; i < statesItems.length; i++) {
            items.add(statesItems[i]);
        }

        return items;
    }
}
